package com.tjing.bussiness.services;

import java.lang.reflect.InvocationTargetException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.tjing.bussiness.support.BusinessException;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;
import org.directwebremoting.WebContext;
import org.directwebremoting.WebContextFactory;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

import com.tjing.bussiness.object.PrintInfo;
import com.tjing.bussiness.object.SaleReturn;
import com.tjing.bussiness.support.MessagePush;
import com.tjing.frame.model.User;
import com.tjing.frame.services.DbServices;
import com.tjing.frame.util.CodeHelper;
import com.tjing.frame.util.OrderCodeGen;
import com.tjing.frame.util.SimpleDao;

@Service
public class BaseDwr {
    @Autowired
    private SimpleDao simpleDao;
    @Autowired
    private MessagePush messagePush;
    @Autowired
    private MemberDwr memberDwr;

    final Logger logger = LoggerFactory.getLogger(BaseDwr.class);



    public Integer balanceSale() {
        try {
            User user = CodeHelper.getCurrentUser();
            Map<Integer, Object> paramMap = new HashMap<Integer, Object>();
            paramMap.put(0, new Date());
            paramMap.put(1, user.getId());
		/*	simpleDao.executeHql(
					"update TicketSale set status='0211002',balanceTime=? where status='0211001' and balanceTime is null and createUserId=? and date_format(createTime,'%Y-%m-%d')=date_format(now(),'%Y-%m-%d')",
					paramMap);*/

            simpleDao.executeSql("update bi_ticket_Sale set status='0211002',balance_time=? where status='0211001' and balance_time is null and create_user_id=? and date_format(create_time,'%Y-%m-%d')=date_format(now(),'%Y-%m-%d')", paramMap);
            return 0;
        } catch (Exception e) {
            System.out.println(e.toString());
            e.printStackTrace();
            return 1;
        }
    }

}
